<template>
	<view class="mainpadding beijingse">
		<view class="ffffff  radius">
			<view class="huanbox flexcenter">会员类型</view>
			<view class="mainpadding2">
				<view class="flexleft flex_wrap">
					<view class="sanshis flexcenter" v-for="item in list" :key="item.id" @click="currentid=item.id">
						<view class="yixbtn flexcenter dingwei margin_top" v-if="currentid==item.id">
							<view class="">
								<view class="ershil xiaocheng textcenter">{{item.name}}</view>
								<view class="ershil xiaocheng smalltext textcenter">￥
									<text class="sanshier fonweight xiaocheng">{{Number(item.price).toFixed()}}</text>
								</view>
							</view>
							<view class="duigbox flexcenter">
								<u-icon name="checkmark" color="#fff" size="12"></u-icon>
							</view>
						</view>
						<view class="weixbtn flexcenter margin_top" v-else>
							<view class="">
								<view class="ershil xiaohui textcenter">{{item.name}}</view>
								<view class="ershil xiaohui smalltext textcenter">￥
									<text class="sanshier fonweight xiaohui">{{Number(item.price).toFixed()}}</text>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="gudingdb ffffff mainpadding" @click="tzsplb">
			<view class="bigbtn">提交</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				currentid:"",
				list:[],
				level:0,//当前会员等级
			}
		},
		onLoad() {
			this.init()
			this.getuserinfo()
		},
		methods: {
			getuserinfo() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					this.level = res.data.level
				})
			},
			init() { //获取轮播图
				httpRequest.request('/api/goods/userLevel', 'POST', {
				}).then(res => {
					this.list = res.data
					this.currentid = res.data[0].id
				}).catch(err => {})
			},
			// 跳转商品列表
			tzsplb() {
				if(this.level>=this.currentid){
					httpRequest.toast("请升级比当前等级高的会员等级")
					return false
				}
				uni.navigateTo({
					url: '/pages_homepage/huiyuanshangplb?user_level_id='+this.currentid
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.weixbtn {
		width: 196rpx;
		height: 110rpx;
		background: rgba(102, 102, 102, .1);
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		border: 2rpx solid rgba(102, 102, 102, .1);
	}

	.duigbox {
		position: absolute;
		bottom: 0;
		right: 0;
		width: 30rpx;
		height: 24rpx;
		background: #FF8505;
		border-radius: 8rpx 0rpx 8rpx 0rpx;
		opacity: 1;
	}

	.yixbtn {
		width: 196rpx;
		height: 110rpx;
		background: rgba(255, 133, 5, 0.1);
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		border: 2rpx solid #FF8505;
	}

	.huanbox {
		font-size: 28rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 800;
		color: #FF9341;
		padding: 16rpx 0;
		background: #FF9341;
		// border-radius: 6rpx 6rpx 0rpx 0rpx;
		background-color: rgba(255, 147, 65, .1);
	}
</style>